package cn.tansanqinger.ThreadPool;

import java.util.concurrent.*;

public class ThreadPoolExecutorDemo {
    public static void main(String[] args) {
        /**
         * 参数一：核心线程数（常驻线程）
         * 参数二：最大线程数
         * 参数三：存活时间
         * 参数四：时间单位
         * 参数五：等待队列
         * 参数六：线程工厂
         * 参数七：拒绝策略
         */
		ExecutorService executorService = new ThreadPoolExecutor(3,5,1L, TimeUnit.SECONDS,new ArrayBlockingQueue<Runnable>(3), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());
		for (int i = 0; i < 10; i++) {
			executorService.execute(()->{
				System.out.println(Thread.currentThread().getName());
			});
		}
		executorService.shutdown();
    }
}
